﻿#pragma once

#include <QWidget>
#include<qmetatype.h>
#include<qstandarditemmodel.h>
#include"Song.h"
#include<qlist.h>
#include<qmap.h>

class QMutex;
class MusicListDelegate;
class MusicListView;

class MusicList  : public QWidget
{
	Q_OBJECT

public:
	//enum class ListType:char
	//{
	//	PlayList,
	//	RectentList,
	//	SearchList
	//};

	enum class PlayMode:char
	{
		PlayInOrder,	//顺序播放
		Shuffle,		//随机播放
		RepeatSingle,	//单曲循环
		//RepeatAll,		//列表循环
		//SingleMode		//单曲播放
	};

	MusicList(QWidget*parent = nullptr);
	~MusicList();

	void appendSong(const Song& song);
	void appendSong(const QList<Song>& list);
	void push_back(const Song& song);
	void push_back(const QList<Song>& list);
	void push_front(const Song& song);
	//void switchList(ListType type);
	QUrl nextMusic();
	QUrl prevMusic();
	MusicList::PlayMode playMode() const;
	void helightRow(int index);



signals:
	void appendSongFinished(QStandardItem* item);
	void push_frontFinished(QStandardItem* item);
	void doubleClicked(QUrl song);
private:
	int m_playIndex;
	PlayMode m_playMode;
	//ListType m_listType;
	MusicListView* m_listView;

	//QMap<ListType,QStandardItemModel*> m_models;
	MusicListDelegate* m_delegate;
	QMutex* m_mutex;
	QStandardItemModel* m_curModel;
	void initAllConnect();
	
};

#ifndef Q_DECLARE_METATYPE(QList<Song>)

Q_DECLARE_METATYPE(QList<Song>)

#endif // Q_DECLARE_METATYPE(QList<Song>)


